package libnetdb.dm.assoc.base;

/**
 * <code>Recommendation</code> basically consists of two parts,
 * i.e., item and confidence, where the item is the recommended
 * item and the confidence is the highest value of confidence
 * amoung all the supported rules. Note that this class is
 * <code>Comparable</code> base the confidence value of the two
 * instances.
 *
 * @author Cheng-Ru Lin
 * @version 1.0
 */

public class Recommendation implements Comparable{
    private int item;
    private double confidence;
    private Rule rule;

    Recommendation(int item, Rule rule){
        this.item = item;
        this.rule = rule;
        this.confidence = rule.getConfidence();
    }

    public int compareTo(Object obj){
        double x = confidence - ((Recommendation)obj).confidence;
        return x > 0 ? 1 : x < 0 ? -1 : 0;
    }

    /**
     * Gets the recommended item.
     *
     * @return the recommended item
     */
    public int getItem(){
        return item;
    }

    /**
     * Gets the highest confidence of the rule which recommend
     * this item.
     *
     * @return the confidence of recommend this item
     */
    public double getConfidence(){
        return confidence;
    }

    /**
     * Gets the rule which supports this recommendation.
     *
     * @return the rule which supports this recommendation.
     */
    public Rule getRule(){
        return rule;
    }


}
